const state = {
  payName: null, // 支付方式名称
  payDesc: null, // 支付方式相关的信息，如卡号或余额
  amount: null, // 钱包余额
  getUnpayCountResult: 0, // 获取失败行程数量结果: 0 未获取 1协议成功 2协议失败
  getPaymentResult: 0 // 获取支付方式结果: 0 未获取 1协议成功 2协议失败
}

const getters = {
  payName: state => state.payName,
  payDesc: state => state.payDesc,
  amount: state => state.amount,
  getUnpayCountResult: state => state.getUnpayCountResult,
  getPaymentResult: state => state.getPaymentResult
}

const actions = {
  fetchPayName: ({ commit, state }, text) => {
    commit('updatePayName', text)
  },
  fetchPayDesc: ({ commit, state }, text) => {
    commit('updatePayDesc', text)
  },
  fetchAmount: ({ commit, state }, text) => {
    commit('updateAmount', text)
  },
  fetchGetUnpayCountResult: ({ commit, state }, text) => {
    commit('updateGetUnpayCountResult', text)
  },
  fetchGetPaymentResult: ({ commit, state }, text) => {
    commit('updateGetPaymentResult', text)
  }
}

const mutations = {
  updatePayName: (state, payload) => {
    state.payName = payload
  },
  updatePayDesc: (state, payload) => {
    state.payDesc = payload
  },
  updateAmount: (state, payload) => {
    state.Amount = payload
  },
  updateGetUnpayCountResult: (state, payload) => {
    state.getUnpayCountResult = payload
  },
  updateGetPaymentResult: (state, payload) => {
    state.getPaymentResult = payload
  }
}

export default {
  state,
  getters,
  actions,
  mutations
}
